import sys
from PyQt5 import QtCore,  QtWidgets
from PyQt5.QtCore import Qt
from ui_dlgYanghua import Ui_Form
import copy
from  Mole import Mole
class DlgYanghua(QtWidgets.QDialog):
    ui = Ui_Form()

    def __init__(self, parent=None):
        QtWidgets.QDialog.__init__(self, parent)
        self.ui.setupUi(self)
        # self.setWindowTitle("方法编号")
 
        self.ui.lineEdit_ele.setText("C")
        self.ui.edit_yanghua.setText("CO2")
        self.ui.edit_xishu.setText("1.4")

        self.ui.btn_ok.clicked.connect(self.ok)
        self.ui.btn_cancel.clicked.connect(self.cancel)
        self.ui.edit_yanghua.textChanged.connect(self.calc)
    def calc(self):
        try:
            m=self.ui.edit_yanghua.text()
            xishu=Mole.Xishu(m)
            self.ui.edit_xishu.setText(str(xishu))
        except TypeError:
            pass
    def ok(self):
        self.accept()

    def cancel(self):
        self.reject()

if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)
    window = DlgYanghua()
    window.show()
    app.exec()
